﻿using WebFoundation;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MHI.DeviceManager.Interfaces
{
    /// <summary>
    /// DevLocationinfoT,table entity: dev_locationinfo_t
    /// </summary>
    public class DevLocationinfoT : INotifyPropertyChanged
    {
        public static readonly string KeyId;
        public static readonly string KeyName;
        public static readonly string KeyCode;
        public static readonly string KeyParentId;
        public static readonly string KeyLocation;
        public static readonly string KeyRemark;
        public static readonly string KeyGmtCreated;
        public static readonly string KeyPersonModified;
        public static readonly string KeyGmtModified;
        public static readonly string KeyStateInfo;
        public static readonly string KeyIsUse;
        public static readonly string KeyVersion;

        static DevLocationinfoT()
        {
            KeyId = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.Id);
            KeyName = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.Name);
            KeyCode = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.Code);
            KeyParentId = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.ParentId);
            KeyLocation = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.Location);
            KeyRemark = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.Remark);
            KeyGmtCreated = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.GmtCreated);
            KeyPersonModified = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.PersonModified);
            KeyGmtModified = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.GmtModified);
            KeyStateInfo = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.StateInfo);
            KeyIsUse = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.IsUse);
            KeyVersion = ExpressionHelper.GetPropertyName<DevLocationinfoT>(r => r.Version);
        }

        private int _id;
        private string _name;
        private string _code;
        private int _parentId;
        private string _location;
        private string _remark;
        private DateTime _gmtCreated;
        private string _personModified;
        private DateTime _gmtModified;
        private double _stateInfo;
        private int _isUse;
        private int _version;

        /// <summary>
        /// 编码 , column: id required
        /// </summary>
        [Required]
        public int Id
        {
            get { return _id; }
            set
            {
                if (_id != value)
                {
                    _id = value;
                    NotifyOfChange(KeyId);
                }
            }
        }

        /// <summary>
        /// 名称 , column: name 
        /// </summary>
        [StringLength(50)]
        public string Name
        {
            get { return _name; }
            set
            {
                if (_name != value)
                {
                    _name = value;
                    NotifyOfChange(KeyName);
                }
            }
        }

        /// <summary>
        /// 编号 , column: code 
        /// </summary>
        [StringLength(20)]
        public string Code
        {
            get { return _code; }
            set
            {
                if (_code != value)
                {
                    _code = value;
                    NotifyOfChange(KeyCode);
                }
            }
        }

        /// <summary>
        /// 父节点 , column: parent_id 
        /// </summary>
        public int ParentId
        {
            get { return _parentId; }
            set
            {
                if (_parentId != value)
                {
                    _parentId = value;
                    NotifyOfChange(KeyParentId);
                }
            }
        }

        /// <summary>
        /// 坐标 , column: location 
        /// </summary>
        [StringLength(40)]
        public string Location
        {
            get { return _location; }
            set
            {
                if (_location != value)
                {
                    _location = value;
                    NotifyOfChange(KeyLocation);
                }
            }
        }

        /// <summary>
        /// 备注 , column: remark 
        /// </summary>
        [StringLength(100)]
        public string Remark
        {
            get { return _remark; }
            set
            {
                if (_remark != value)
                {
                    _remark = value;
                    NotifyOfChange(KeyRemark);
                }
            }
        }

        /// <summary>
        /// 创建时间 , column: gmt_created 
        /// </summary>
        public DateTime GmtCreated
        {
            get { return _gmtCreated; }
            set
            {
                if (_gmtCreated != value)
                {
                    _gmtCreated = value;
                    NotifyOfChange(KeyGmtCreated);
                }
            }
        }

        /// <summary>
        /// 更新人 , column: person_modified 
        /// </summary>
        [StringLength(10)]
        public string PersonModified
        {
            get { return _personModified; }
            set
            {
                if (_personModified != value)
                {
                    _personModified = value;
                    NotifyOfChange(KeyPersonModified);
                }
            }
        }

        /// <summary>
        /// 更新时间 , column: gmt_modified 
        /// </summary>
        public DateTime GmtModified
        {
            get { return _gmtModified; }
            set
            {
                if (_gmtModified != value)
                {
                    _gmtModified = value;
                    NotifyOfChange(KeyGmtModified);
                }
            }
        }

        /// <summary>
        /// 标识状态 , column: state_info 
        /// </summary>
        public double StateInfo
        {
            get { return _stateInfo; }
            set
            {
                if (_stateInfo != value)
                {
                    _stateInfo = value;
                    NotifyOfChange(KeyStateInfo);
                }
            }
        }

        /// <summary>
        /// 是否可用 , column: is_use 
        /// </summary>
        [Required]
        public int IsUse
        {
            get { return _isUse; }
            set
            {
                if (_isUse != value)
                {
                    _isUse = value;
                    NotifyOfChange(KeyIsUse);
                }
            }
        }

        /// <summary>
        /// 版本 , column: version 
        /// </summary>
        [Required]
        public int Version
        {
            get { return _version; }
            set
            {
                if (_version != value)
                {
                    _version = value;
                    NotifyOfChange(KeyVersion);
                }
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyOfChange(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}